class Solution:
    def computeArea(self, A: int, B: int, C: int, D: int, E: int, F: int, G: int, H: int) -> int:
        width = min(C, G) - max(A, E)
        height = min(D, H) - max(B, F)
        s = width * height if width > 0 and height > 0 else 0
        return (C - A) * (D - B) - s + (G - E) * (H - F)